package com.elitesland.org.entity;

import com.elitesland.core.base.BaseModel;
import com.elitesland.system.annotation.Comment;
import com.elitesland.system.convert.BooleanToIntegerConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "org_address_book")
@org.hibernate.annotations.Table(appliesTo = "org_address_book", comment = "地址簿")
@Data
@Accessors(chain = true)
@ApiModel(value = "地址簿", description = "地址簿")
public class OrgAddressBookDO extends BaseModel implements Serializable {

    private static final long serialVersionUID = -9112491986985798209L;

    @ApiModelProperty(value = "地址簿类型:[UDC]ORG:ADDR_TYPE")
    @Comment("地址簿类型:[UDC]ORG:ADDR_TYPE")
    @Column()
    String addressType;

    @ApiModelProperty(value = "记录ID")
    @Comment("记录ID")
    @Column()
    Long recordId;

    @ApiModelProperty(value = "是否主记录，类似默认")
    @Comment("是否主记录，类似默认")
    @Column()
    @Convert(converter = BooleanToIntegerConverter.class)
    Boolean isPrimary;

    @ApiModelProperty(value = "国家")
    @Comment("国家")
    @Column()
    String country;

    @ApiModelProperty(value = "省份")
    @Comment("省份")
    @Column()
    String province;

    @ApiModelProperty(value = "城市")
    @Comment("城市")
    @Column()
    String city;

    @ApiModelProperty(value = "区县")
    @Comment("区县")
    @Column()
    String county;

    @ApiModelProperty(value = "街道")
    @Comment("街道")
    @Column()
    String community;

    @ApiModelProperty(value = "详细地址")
    @Comment("详细地址")
    @Column()
    String addressLine;

    @ApiModelProperty(value = "邮政编码")
    @Comment("邮政编码")
    @Column()
    String postalCode;

    @ApiModelProperty(value = "联系人")
    @Comment("联系人")
    @Column()
    String contact;

    @ApiModelProperty(value = "手机号码")
    @Comment("手机号码")
    @Column()
    String mobile;

    @ApiModelProperty(value = "联系关系:[UDC]ORG:ADDRLNKT")
    @Comment("联系关系:[UDC]ORG:v ")
    @Column()
    String linkType;

    @ApiModelProperty(value = "开户行")
    @Comment("开户行")
    @Column()
    String bankName;

    @ApiModelProperty(value = "银行账号")
    @Comment("银行账号")
    @Column()
    String bankAccount;


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof OrgAddressBookDO)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        OrgAddressBookDO entity = (OrgAddressBookDO) o;
        return getId().equals(entity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId());
    }
}